package com.distribution.system.domain.converter;


import com.distribution.system.domain.dto.CmccDaOrderListDTO;
import com.distribution.system.domain.req.CmccDaOrderListExportReq;
import com.distribution.system.domain.req.CmccDaOrderListReq;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.time.LocalDateTime;
import java.util.Objects;

@Mapper(componentModel = "spring", imports = {LocalDateTime.class, Objects.class})
public interface CmccDaOrderWebConverter {

    CmccDaOrderListDTO cmccDaOrderListReqToDto(CmccDaOrderListReq cmccDaOrderListReq);

    @Mapping(target = "beginTime", expression = "java(Objects.isNull(cmccDaOrderListExportReq.getBeginTime()) ? null : LocalDateTime.parse(cmccDaOrderListExportReq.getBeginTime()))")
    @Mapping(target = "endTime", expression = "java(Objects.isNull(cmccDaOrderListExportReq.getEndTime()) ? null : LocalDateTime.parse(cmccDaOrderListExportReq.getEndTime()))")
    CmccDaOrderListDTO cmccDaOrderListExportReqToDto(CmccDaOrderListExportReq cmccDaOrderListExportReq);
}
